import { ref } from 'vue';
import { defineStore } from 'pinia';

export const useUserStore = defineStore(
  'user',
  () => {
    const userInfo = ref<{
      isLogin: boolean;
      token: string;
      userMsg: any;
      historyChatUserIdObj: any;
    }>({
      isLogin: false,
      token: '',
      userMsg: {},
      historyChatUserIdObj: {},
    });
    function logout() {
      userInfo.value.isLogin = false;
      userInfo.value.token = '';
      userInfo.value.userMsg = {};
    }
    return { userInfo, logout };
  },
  {
    persist: true,
  }
);
